//https://leetcode.cn/problems/subsets/solutions/420294/zi-ji-by-leetcode-solution/?envType=study-plan-v2&envId=top-100-liked
//重要题目！！！
#include <string>
#include <vector>
#include <set>
#include <iostream>

using namespace std;

class Solution {
public:
    void dfs(vector<int>& nums,std::vector<int> cur_vec,int location,vector<vector<int>>&res) {
        if(nums.size()==location){
            res.push_back(cur_vec);
            return ;
        }
        dfs(nums,cur_vec,location+1,res);
        cur_vec.push_back(nums[location]);
        dfs(nums,cur_vec,location+1,res);
    }
    vector<vector<int>> subsets(vector<int>& nums) {
        vector<vector<int>> res{};
        if (nums.empty()) return res;
        dfs(nums,{},0,res);
        return res;
    }
};

class Solution {
public:
    void dfs(vector<int>& nums,std::vector<int>& cur_vec,int location,vector<vector<int>>&res) {
        if(nums.size()==location){
            res.push_back(cur_vec);
            return ;
        }
        dfs(nums,cur_vec,location+1,res);
        cur_vec.push_back(nums[location]);
        dfs(nums,cur_vec,location+1,res);
        cur_vec.pop_back();
    }
    vector<vector<int>> subsets(vector<int>& nums) {
        vector<vector<int>> res{};
        if (nums.empty()) return res;
        std::vector<int> cur_vec;
        dfs(nums,cur_vec,0,res);
        return res;
    }
};